<template>
    <div>
        {{ info }}
        <h1>门店添加</h1>
        <table class="table table-bordered">
            <tbody>
                <tr>
                    <td align="right">房间号</td>
                    <td><input type="text" v-model="info.FJH"></td>
                </tr>
                <tr>
                    <td align="right">门店外建</td>
                    <td>
                        <select v-model="info.ShopId">
                            <option value="">请选择</option>
                            <option :value="itme.Id"  v-for="itme in lisr.list":key="itme.Id"> {{ itme.ShopName }}</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td align="right">房型外建</td>
                    <td>
                        <select v-model="info.HouserID">
                            <option value="">请选择</option>
                           <option :value="itme.Id"  v-for="itme in lise.list":key="itme.Id"> {{ itme.HouseTypeName }}</option>
                        </select>
                    </td>
                </tr>   

                <tr>
                    <td align="right">房态</td>
                    <td>
                        <select v-model="info.LX">
                            <option value="">请选择</option>
                            <option :value="1">空房</option>
                            <option :value="2">已入住</option>
                            <option :value="3">已预订</option>
                        </select>
                    </td>
                </tr> 
                <tr>
                    <td align="right"></td>
                    <td><input type='button' value="添加" class="btn btn-primary" @click="ok"></td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {ref,reactive,onMounted} from 'vue'
import axios from 'axios';
import { useRouter } from 'vue-router';
const rouder=useRouter();

let info:any=reactive({
  FJH: '',
  ShopId: '',
  HouserID: '',
  LX: ''
})

let lisr:any=reactive({
    a:[]
})
let lise:any=reactive({
    a:[]
})
let info1:any=reactive({
    pageIndex:1,
    pagesize:100,
    names:'',
    addres:''
})
let info2:any=reactive({
    pageIndex:1,
    pagesize:100
})
onMounted(()=>{
    getlist();
    getlists();
})
const getlist=()=>{
    axios({
        url:'/api/Shop/GetShow',
        method:'get',
        params:info1
    })
    .then((res)=>{
        console.log(res);
        Object.assign(lisr,res.data)
    })
    .catch((err)=>{
        console.log(err);
        
    })

}







const getlists=()=>{
    axios({
        url:'/api/Houser/GetShow',
        method:'get',
        params:info2
    })
    .then((res)=>{
        console.log(res);
        Object.assign(lise,res.data)
    })
    .catch((err)=>{
        console.log(err);
        
    })

}



const ok=()=>{
    axios({
        url:'/api/FX/Add',
        method:'post',
        data:info
    })
    .then((res)=>{
        console.log(res);
        if(res.data==-1)
    {
        alert('房间号重复');
        return;
    }
    if(res.data>0)
    {
        alert('添加成功');
        rouder.push("/shopshow")
        
        return;
    }
    else
    {
        alert('添加失败');
        return;
    }
    })
    .catch((err)=>{
        console.log(err);
        
    })
}
</script>

<style scoped>

</style>